"""
Gemini: What is an array.array in python?

**`array.array` in Python** is a specialized data structure that provides a more efficient way to store and manipulate homogeneous sequences of basic data types (like integers, floats, characters). Unlike regular Python lists, which can store elements of mixed data types, `array.array` is designed to handle only elements of the same type.

**Key features and differences from regular Python lists:**

* **Homogeneous data types:** All elements in an `array.array` must be of the same type (e.g., `'i'` for integers, `'f'` for floats, `'b'` for signed bytes).
* **Efficient memory usage:** `array.array` is typically more memory-efficient than regular Python lists, especially when dealing with large amounts of data.
* **Faster operations:** Certain operations, like appending or slicing elements, can be more efficient with `array.array` compared to regular lists.
* **Limited functionality:** `array.array` doesn't have all the methods and features of regular lists. For example, you can't use methods like `append` or `extend` directly.

**Example:**

```python
import array

# Create an array of integers
numbers = array.array('i', [1, 2, 3, 4, 5])

# Access elements by index
print(numbers[0])  # Output: 1
print(numbers[2])  # Output: 3

# Modifying elements
numbers[3] = 10
print(numbers)  # Output: array('i', [1, 2, 3, 10, 5])

# Adding elements using the `fromlist` method
numbers.fromlist([6, 7])
print(numbers)  # Output: array('i', [1, 2, 3, 10, 5, 6, 7])
```

**When to use `array.array`:**

* **Performance-critical applications:** If you're dealing with large amounts of numerical data and need the best possible performance, `array.array` can be a good choice.
* **When you need to store homogeneous data types efficiently:** If all the elements in your sequence are of the same type, `array.array` can be more efficient than regular lists.

**In most cases, regular Python lists are sufficient for general-purpose data storage. However, when performance and memory efficiency are critical, `array.array` can be a valuable tool.**

"""

# https://docs.python.org/3/library/array.html

import array

# numbers = array.array('i', [1, 2, 3, 4, 5])
numbers = array.array('B', [1, 2, 3, 4, 5])
print(numbers[0])
print(numbers[2])
print('numbers:', numbers)
numbers[3] = 44
print('numbers:', numbers)

numbers.fromlist([6, 7, ])
print('numbers:', numbers)
